package top.roadvast.springboot.base64_test.utils;

import java.nio.charset.StandardCharsets;
import java.util.Base64;

/**
 * @Author 郭泽鹏
 * @Date 2021/10/24 20:50
 * @Version 1.0
 * @Description 使用jdk8实现base64加密解密
 */
public class JdkBase64Util {
    public static String jdkBase64Encode(String str) {
        return  Base64.getEncoder().encodeToString(str.getBytes(StandardCharsets.UTF_8));
    }

    public static String jdkBase64Decode(String str) {
        byte[] decode = Base64.getDecoder().decode(str.getBytes(StandardCharsets.UTF_8));
        return new String(decode, StandardCharsets.UTF_8);
    }
}
